import inspect
from functools import wraps

def coroutine(f):
    @wraps(f)
    def wrapper(*args,**kwargs):
        g=f(*args,**kwargs)
        next(g)
        return g
    return wrapper

@coroutine
def generator():
    i='activate'
    while True:
        try:
            value=yield i
        except ValueError:
            print('over')
        i=value

h=generator()
print(inspect.getgeneratorstate(h))
